package com.pay.game.central.web.mapper;

import com.github.pagehelper.Page;
import com.pay.game.central.web.bean.PddCustomer;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface PddCustomerMapper {

    @Insert("<script> "+
            "   insert into pdd_customer(id,tel,create_time) values "+
            "       <foreach collection=\"pddCustomers\" item=\"item\" separator=\",\"> "+
            "           (#{item.id},#{item.tel},#{item.create_time,jdbcType=BIGINT}) "+
            "       </foreach>"+
            "</script>")
    void addCustomers(@Param("pddCustomers") List<PddCustomer> pddCustomers);

    @Select("<script>" +
            "   select * from pdd_customer where 1=1" +
            "   <if test=\"tel!=null and tel!=''\"> " +
            "       and tel=#{tel}" +
            "   </if>"+
            "   <if test='status!=-1'> " +
            "       and status=#{status,jdbcType=TINYINT}" +
            "   </if>"+
            "</script>" )
    Page<PddCustomer> list(@Param("tel") String tel, @Param("status")int status);

    @Select("select tel from pdd_customer")
    List<String> allTel();
}
